/**
 * 项目反馈模型
 */
const { BaseModel } = require('../config/models_config');

class ProjectFeedbackModel extends BaseModel {
    constructor() {
        super();
        this.setCollection('project_feedback');
    }

    /**
     * 反馈类型：1=功能问题, 2=性能问题, 3=质量问题, 4=建议, 5=其他
     */
    static TYPE = {
        FUNCTION: 1,
        PERFORMANCE: 2,
        QUALITY: 3,
        SUGGESTION: 4,
        OTHER: 5
    };

    /**
     * 反馈类型描述
     */
    static TYPE_DESC = {
        FUNCTION: '功能问题',
        PERFORMANCE: '性能问题',
        QUALITY: '质量问题',
        SUGGESTION: '建议',
        OTHER: '其他'
    };

    /**
     * 优先级：1=低, 2=中, 3=高, 4=紧急
     */
    static PRIORITY = {
        LOW: 1,
        MEDIUM: 2,
        HIGH: 3,
        URGENT: 4
    };

    /**
     * 优先级描述
     */
    static PRIORITY_DESC = {
        LOW: '低',
        MEDIUM: '中',
        HIGH: '高',
        URGENT: '紧急'
    };

    /**
     * 状态：1=待处理, 2=处理中, 3=已解决, 4=已拒绝, 5=已关闭
     */
    static STATUS = {
        PENDING: 1,
        PROCESSING: 2,
        RESOLVED: 3,
        REJECTED: 4,
        CLOSED: 5
    };

    /**
     * 状态描述
     */
    static STATUS_DESC = {
        PENDING: '待处理',
        PROCESSING: '处理中',
        RESOLVED: '已解决',
        REJECTED: '已拒绝',
        CLOSED: '已关闭'
    };

    /**
     * 验证结果：1=通过, 2=不通过
     */
    static VERIFICATION_RESULT = {
        PASS: 1,
        FAIL: 2
    };

    /**
     * 验证结果描述
     */
    static VERIFICATION_RESULT_DESC = {
        PASS: '通过',
        FAIL: '不通过'
    };

    /**
     * 获取类型名称
     * @param {number} type 类型
     * @returns {string} 类型名称
     */
    static getTypeName(type) {
        const typeMap = {
            [this.TYPE.FUNCTION]: this.TYPE_DESC.FUNCTION,
            [this.TYPE.PERFORMANCE]: this.TYPE_DESC.PERFORMANCE,
            [this.TYPE.QUALITY]: this.TYPE_DESC.QUALITY,
            [this.TYPE.SUGGESTION]: this.TYPE_DESC.SUGGESTION,
            [this.TYPE.OTHER]: this.TYPE_DESC.OTHER
        };
        return typeMap[type] || '未知类型';
    }

    /**
     * 获取优先级名称
     * @param {number} priority 优先级
     * @returns {string} 优先级名称
     */
    static getPriorityName(priority) {
        const priorityMap = {
            [this.PRIORITY.LOW]: this.PRIORITY_DESC.LOW,
            [this.PRIORITY.MEDIUM]: this.PRIORITY_DESC.MEDIUM,
            [this.PRIORITY.HIGH]: this.PRIORITY_DESC.HIGH,
            [this.PRIORITY.URGENT]: this.PRIORITY_DESC.URGENT
        };
        return priorityMap[priority] || '未知优先级';
    }

    /**
     * 获取状态名称
     * @param {number} status 状态
     * @returns {string} 状态名称
     */
    static getStatusName(status) {
        const statusMap = {
            [this.STATUS.PENDING]: this.STATUS_DESC.PENDING,
            [this.STATUS.PROCESSING]: this.STATUS_DESC.PROCESSING,
            [this.STATUS.RESOLVED]: this.STATUS_DESC.RESOLVED,
            [this.STATUS.REJECTED]: this.STATUS_DESC.REJECTED,
            [this.STATUS.CLOSED]: this.STATUS_DESC.CLOSED
        };
        return statusMap[status] || '未知状态';
    }
}

module.exports = ProjectFeedbackModel; 